package com.realgodo.site.entity.application.communication;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import com.realgodo.site.entity.application.Application;


/**评论实体*/
@Entity(name = "Commentary")
@Table(name = "commentary")
@Inheritance(strategy = InheritanceType.JOINED)
@PrimaryKeyJoinColumn(name = "id", referencedColumnName = "id")
public class Commentary extends Communication{

	/***/
	private static final long serialVersionUID = 6637391750365541060L;
	/***/
	Application application;
	/**回复列表*/
	private List<Reply> replyList;
	
	@ManyToOne
	@JoinColumn(name = "application_id", referencedColumnName = "id", nullable = false)
	public Application getApplication() {
		return application;
	}

	public void setApplication(Application application) {
		this.application = application;
	}

	@OneToMany(fetch = FetchType.EAGER, mappedBy = "commentary",cascade = CascadeType.REMOVE)
	public List<Reply> getReplyList() {
		if(replyList==null){
			replyList=new ArrayList<Reply>();
		}
		return replyList;
	}

	public void setReplyList(List<Reply> replyList) {
		this.replyList = replyList;
	}

	
}
